@echo off
setlocal

rem set /p hostname="输入数据库所在主机的 IP 地址："
set /p username="输入 MySQL 用户名："
set /p comment="输入备注信息："

for /f "tokens=2 delims==" %%i in ('wmic os get localdatetime /value') do set datetime=%%i

set year=%datetime:~0,4%
set month=%datetime:~4,2%
set day=%datetime:~6,2%
set hour=%datetime:~8,2%
set minute=%datetime:~10,2%
set second=%datetime:~12,2%

set timestamp=%year%-%month%-%day%_%hour%-%minute%-%second%

set outputfile=petstore_%timestamp%_%comment%.sql

mysqldump -h "localhost" -u %username% -p --databases petstore > %outputfile%

endlocal
pause